import router from "@/router";
import { toast } from "vant";
import { crowds, colorDetails,participate , participateIssue , buyLotteryTicket,transfer,rearing,past} from "@/server/crowdfry";
import { setStorage, setSession, removeStorage } from "@/utils/common";
export default {
  state: () => ({}),
  mutations: {},
  actions: {
    crowds({ commit }, data) {
      return new Promise((resolve, reject) => {
        crowds(data).then((res) => {
          if (res.code == 0) {
            resolve(res.data);
          }
        });
      });
    },
    colorDetails({ commit }, data) {
      return new Promise((resolve, reject) => {
        colorDetails(data).then((res) => {
          if (res.code == 0) {
            resolve(res);
          }
        });
      });
    },
    participate({ commit }, data) {
      return new Promise((resolve, reject) => {
        participate(data).then((res) => {
          if (res.code == 0) {
            resolve(res.data);
          }
        });
      });
    },
    participateIssue({ commit }, data) {
      return new Promise((resolve, reject) => {
        participateIssue(data).then((res) => {
          if (res.code == 0) {
            resolve(res.data);
          }
        });
      });
    },
    buyLotteryTicket({ commit }, data) {
      return new Promise((resolve, reject) => {
        buyLotteryTicket(data).then((res) => {
            resolve(res);
        });
      });
    },
    transfer({ commit }, data) {
      return new Promise((resolve, reject) => {
        transfer(data).then((res) => {
          if (res.code == 0) {
            resolve(true);
          }else{
            resolve(false)
            toast(res.msg)
          }
        });
      });
    },
    rearing({ commit }, data) {
      return new Promise((resolve, reject) => {
        rearing(data).then((res) => {
          if (res.code == 0) {
            resolve(res.data);
          }else{
            toast(res.msg)
          }
        });
      });
    },
    past({ commit }, data) {
      return new Promise((resolve, reject) => {
        past(data).then((res) => {
          if (res.code == 0) {
            resolve(res.data);
          }
        });
      });
    },     
  },
  getters: {},
};
